<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
export default {
  name: "App",
  data() {
    return {
      interval: "",
    };
  },
  created() {
    this.$store.dispatch("user/refreshToken").then((response) => {
      if (this.$route.query.redirect) {
        this.$router.push(this.$route.query.redirect); // 如果有 redirect说明应该没有token或者token失效跳到了登录页，跳回原页面
      }
    });
 
    this.interval = setInterval(() => {
      this.$store.dispatch("user/refreshToken")
    }, 9*60*1000);
  },
  beforeDestroy() {
    clearInterval(this.interval);
  },
};
</script>
